<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>ajax</title>
</head>
<body>
    <div id="divId"></div>
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
    <script>
        var ss = '111';
        function test(){
            axios({
                method: 'get',
                //url: 'https://safe-inlet-22848.herokuapp.com/games'
                url: 'http://localhost:8088/index/t/122'
            }).then((response) => {
                document.getElementById("divId").innerHTML=response.data;
                ss = response.data;
                console.log('1:'+ss);
            }, (error) => {
                console.log(error);
            });
        }
        test();
        console.log('2:'+ss);

        var ss2 = '111';
        function test2(){
            $.ajax({
                url: "http://localhost:8088/index/t/122",
                //async: false 取消异步,默认异步:true
                async: false, 
                dataType: 'json',
                success: function (json) {
                    ss2 = json;
                    console.log('111:'+ss2);
                }
            });
        }
        test2();
        console.log('222:'+ss2);

    </script>
</body>
</html>